<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin:0;padding:0}
        img{
            vertical-align: top;
        }
        .main{
            margin:0 auto;
            width:1000px;
            margin-top:10px;

        }
        .fixed {
            position: fixed;
            top: 0;
            left: 0;
        }
    </style>
    <script src="../js/scroll.js"></script>
</head>
<body>
    <div class="top" id="top">
        <img src="images/top.png" alt=""/>
    </div>
    <div id="Q-nav">
        <img src="images/nav.png" alt=""/>
    </div>
    <div class="main" id="main">
        <img src="images/main.png" alt=""/>
    </div>
    <script>
        var oTop=document.querySelector("#top");
        var oNav=document.querySelector("#Q-nav");
        var oMain=document.querySelector("#main");

        window.onscroll=function(){
            let scrollTop=utils.getScroll().top;
            if(scrollTop>oTop.offsetHeight){
                oNav.style.position="fixed";
                oNav.style.top="0px";
                oMain.style.marginTop=oNav.offsetHeight+"px";
            }else{
                oNav.style.position="static";
                oMain.style.marginTop="10px";
            }
        }
    </script>
</body>
</html>